

/** api: example[wms-tree]
 *  WMS Capabilities Tree
 *  ---------------------
 *  Create a tree loader from WMS capabilities documents.
 */

var layerRoot;
var baseLayer;
var treePanel, mapPanel;
var map;

Ext.onReady(function() {

     /***  BASE LAYERS GOOGLE ***/
    
     map=new OpenLayers.Map('map');
     
     //layers google 
    var ghyb=new OpenLayers.Layer.Google(
         "Google HyBrid",
         {
             type: google.maps.MapTypeId.HYBRID ,
             isBaseLayer:true});
              
     var gmap=new OpenLayers.Layer.Google(
             "Google Streets",
         { 
             type:google.maps.MapTypeId.ROADMAP,
             isBaseLayer:true});
     
     var gphy=new OpenLayers.Layer.Google(
         "Google Phsycal",
         { 
             type:google.maps.MapTypeId.TERRAIN,
             isBaseLayer:true});
     
     var osm=new OpenLayers.Layer.OSM();
    
    //add map layers    
    map.addLayers([osm,ghyb,gmap,gphy]); 



    var layerList = new GeoExt.tree.LayerContainer({
    text: 'All Layers',
    layerStore: map.layers,
    expanded: true
    });

    var layerTree=new Ext.tree.TreePanel({
       title:'Map Layers',
       root:layerList
    });
    
    
    
    
    //Base Layers
    baseLayer=new GeoExt.tree.BaseLayerContainer({
       text:"base Layers",
       map:map,
       expanded:true
    }); 
    
    
    
    
    
    //layerRoot.appenChild(baseLayer);
    
    /*layerRoot.appenChild(new GeoExt.tree.BaseLayerContainer({
        text:'Base Layers',
        map:map,
        expanded:true
    }));
    */
   
   

    treePanel = new Ext.tree.TreePanel({
        root: layerList,
        region: 'west',
        width: 250,
        border:'flit',
        split:true,
        title:'Capas',
        collapsible:true,
        margins: '5 5 5 5',
        padding:'2 2 2 2',
        
    });

    mapPanel = new GeoExt.MapPanel({
        zoom: 2,
        layers: [
            new OpenLayers.Layer.WMS("Global Imagery",
                "http://maps.opengeo.org/geowebcache/service/wms", 
                {layers: "bluemarble"},
                {buffer: 0}
            )
        ],
        region: 'center'
    });

    new Ext.Viewport({
        layout: "fit",
        hideBorders: true,
        items: {
            layout: "border",
            deferredRender: false,
            items: [mapPanel, treePanel]
        }
    });

});